package com.zfei.gfb.vo;

import com.zfei.gfb.api.domain.StatsTag;
import com.zfei.gfb.core.Dynamic;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class StatsVo {

    private HouseStats house;
    private GoodsStats goods;
    private CompanyStats company;
    private LandResourceStats landResource;

    public StatsVo() {
        this.house = new HouseStats();
        this.goods = new GoodsStats();
        this.company = new CompanyStats();
        this.landResource = new LandResourceStats();
    }

    @Data
    @Dynamic("select count(0) from gfb_house ")
    @ApiModel("房源统计")
    public static class HouseStats {

        @ApiModelProperty("总数")
        private int total;

        @Dynamic("type = 2")
        @ApiModelProperty("长租房")
        private int big;

        @Dynamic("type = 1")
        @ApiModelProperty("短租房")
        private int small;

        @Dynamic("status = 1")
        @ApiModelProperty("已认证")
        private int verified;

        @Dynamic("status = 0")
        @ApiModelProperty("认证中")
        private int unVerified;

        @Dynamic("status = 2")
        @ApiModelProperty("未通过")
        private int unPass;

        @Dynamic(useParSql = false, value = "select ifnull(sum(num),0) from yx_stats where tag = '" + StatsTag.HOUSE_BROWSE_COUNT + "'")
        @ApiModelProperty("浏览量")
        private long browse;

        @Dynamic(useParSql = false, value = "select ifnull(sum(num),0) from yx_stats where tag = '" + StatsTag.HOUSE_COLLECT_COUNT + "'")
        @ApiModelProperty("收藏量")
        private long collect;

        @Dynamic(useParSql = false, value = "select count(0) from gfb_house_apply")
        @ApiModelProperty("预约人次")
        private int reserve;

    }

    @Data
    @Dynamic("select count(0) from gfb_goods ")
    @ApiModel("物品统计")
    public static class GoodsStats {

        @ApiModelProperty("总数")
        private int total;

        @Dynamic("(status = 2 or status = 3)")
        @ApiModelProperty("已交易物品数量")
        private int traded;

        @Dynamic("sale_type = 1")
        @ApiModelProperty("工分交易物品数量")
        private int workPoint;

        @Dynamic("sale_type = 2")
        @ApiModelProperty("线下交易物品数量")
        private int offline;

        @Dynamic(useParSql = false, isAppend = true, value = "select ifnull(sum(num),0) from yx_stats right join gfb_goods on yx_stats.id = gfb_goods.id where tag = '" + StatsTag.GOODS_BROWSE_COUNT + "' ")
        @ApiModelProperty("浏览量")
        private int browse;

        @Dynamic("status = 3")
        @ApiModelProperty("已兑换")
        private int redeemed;

        @Dynamic("status = 2")
        @ApiModelProperty("未兑换物品数量")
        private int unRedeemed;

        @Dynamic(useParSql = false, isAppend = true, value = "select ifnull(sum(gfb_order.price),0) from gfb_order left join gfb_goods on gfb_goods.id = gfb_order.goods_id where 1=1 ")
        @ApiModelProperty("工分交易总额")
        private int priceNum;
    }

    @Data
    @Dynamic("select count(0) from gfb_company")
    @ApiModel("企业账号统计")
    public static class CompanyStats {

        @Dynamic("audit = 2")
        @ApiModelProperty("企业认证总数")
        private int total;

        @Dynamic(useParSql = false, value = "select ifnull(sum(head_count),0) from gfb_job")
        @ApiModelProperty("招工人数")
        private int recruit;

        @Dynamic(useParSql = false, value = "select count(0) from gfb_job")
        @ApiModelProperty("招工岗位数")
        private int job;

        @Dynamic(useParSql = false, value = "select ifnull(sum(head_count),0) from gfb_job where type = 3")
        @ApiModelProperty("社工招募人数")
        private int socialWorker;

        @Dynamic(useParSql = false, value = "select ifnull(sum(head_count),0) from gfb_job where type = 2")
        @ApiModelProperty("企业招工人数")
        private int comWorker;

        @Dynamic(useParSql = false, value = "select count(0) from gfb_job_wanted")
        @ApiModelProperty("总求职人数")
        private int jobSeeker;

        @Dynamic(useParSql = false, value = "select count(0) from gfb_job where type = 3")
        @ApiModelProperty("社工招募岗位数")
        private int socialJob;

        @Dynamic(useParSql = false, value = "select count(0) from gfb_job where type = 2")
        @ApiModelProperty("企业招工岗位数")
        private int comJob;
    }

    @Data
    @ApiModel("国土资源")
    @Dynamic("select count(0) from gfb_land_resources")
    public static class LandResourceStats {

        @Dynamic(useParSql = false, value = "select count(0) from gfb_green_plot")
        @ApiModelProperty("菜地总数")
        private int gpTotal;

        @Dynamic(useParSql = false, value = "select ifnull(sum(num),0) from yx_stats where tag = '" + StatsTag.GREEN_BROWSE_COUNT + "'")
        @ApiModelProperty("菜地浏览量")
        private int gpBrowse;

        @Dynamic(useParSql = false, value = "select count(0) from gfb_green_plot_apply")
        @ApiModelProperty("菜地认领人次")
        private int gpApply;

        @Dynamic("type = 1")
        @ApiModelProperty("土地招标信息总数")
        private int landTotal;

        @Dynamic(useParSql = false, value = "select count(0) from gfb_land_publicity where type = 1")
        @ApiModelProperty("土地中标公示总数")
        private int landPublicity;

        @Dynamic(useParSql = false, value = "select ifnull(sum(num),0) from yx_stats where tag = '" + StatsTag.LAND_RESOURCE_BROWSE_COUNT + "'")
        @ApiModelProperty("土地招标信息浏览量")
        private int landBrowse;

        @Dynamic(useParSql = false, value = "select ifnull(sum(num),0) from yx_stats where tag = '" + StatsTag.LAND_PUBLICITY_BROWSE_COUNT + "'")
        @ApiModelProperty("土地中标公示浏览量")
        private int landPublicityBrowse;

        @Dynamic("type = 2")
        @ApiModelProperty("池塘招标信息总数")
        private int pondTotal;

        @Dynamic(useParSql = false, value = "select count(0) from gfb_land_publicity where type = 2")
        @ApiModelProperty("池塘中标公示总数")
        private int pondPublicityTotal;

        @Dynamic(useParSql = false, value = "select ifnull(sum(num),0) from yx_stats where tag = '" + StatsTag.POND_RESOURCE_BROWSE_COUNT + "'")
        @ApiModelProperty("池塘招标信息浏览量")
        private int pondBrowse;

        @Dynamic(useParSql = false, value = "select ifnull(sum(num),0) from yx_stats where tag = '" + StatsTag.POND_PUBLICITY_BROWSE_COUNT + "'")
        @ApiModelProperty("池塘中标公示浏览量")
        private int pondPublicityBrowse;

        @Dynamic("type = 3")
        @ApiModelProperty("山林招标信息总数")
        private int mountainTotal;

        @Dynamic(useParSql = false, value = "select count(0) from gfb_land_publicity where type = 3")
        @ApiModelProperty("山林中标公示总数")
        private int mountainPublicityTotal;

        @Dynamic(useParSql = false, value = "select ifnull(sum(num),0) from yx_stats where tag = '" + StatsTag.MOUNTAIN_RESOURCE_BROWSE_COUNT + "'")
        @ApiModelProperty("山林招标信息浏览量")
        private int mountainBrowse;

        @Dynamic(useParSql = false, value = "select ifnull(sum(num),0) from yx_stats where tag = '" + StatsTag.MOUNTAIN_PUBLICITY_BROWSE_COUNT + "'")
        @ApiModelProperty("山林中标公示浏览量")
        private int mountainPublicityBrowse;

    }


}